<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Encore\Admin\Traits\ModelTree;
use Encore\Admin\Traits\AdminBuilder;

class BusinessCategory extends Model
{
    //
    use ModelTree, AdminBuilder;

    protected $table = 'business_categories';

    protected $fillable = ['name','description','order', 'parent_id'];

    public function __construct(array $attributes = [])
    {
        parent::__construct($attributes);

        $this->setParentColumn('parent_id');
        $this->setOrderColumn('order');
        $this->setTitleColumn('name');
    }

    public function businesses()
    {
        return $this->hasMany(Business::class, 'category_id');
    }
}
